#ifndef GX_FR_EDITOR_VIEW_GRID_H
#define GX_FR_EDITOR_VIEW_GRID_H

#include "LibGL/GxUI.h"
#include "View.h"

namespace FinalRendering
{

	namespace Editor
	{
		using GxRendering::UI::UIMouseEventArgs;
		using GxRendering::UI::UI_Base;
		using GxRendering::UI::UI_MsgArgs;

		class ViewGrid : public GxRendering::UI::Container
		{
		private:
			static const int SplitterSize = 8;
			static const int MinSize = 0;
			int sizing;
			Editor::View * curView, *curCapturedView;
			int viewMousePosX, viewMousePosY;
			int lstX, lstY, curX, curY;
			int beforeW, beforeH;
			Editor::View * GetView(UI_Base * viewCtrl);
			void ViewRender(UI_Base * sender);
			void ViewResize(UI_Base * sender);
			void ViewMouseDown(UI_Base * sender, UIMouseEventArgs & e);
			void ViewMouseUp(UI_Base * sender, UIMouseEventArgs & e);
			void ViewMouseMove(UI_Base * sender, UIMouseEventArgs & e);
			void ViewMouseWheel(UI_Base * sender, UIMouseEventArgs & e);
			void ViewKeyDown(UI_Base * sender, UIKeyEventArgs & e);
			void ViewGridKeyDown(UI_Base * sender, UIKeyEventArgs & e);

			void ViewRefreshViews();
			void ViewGetCurrentScene(Scene *& scene);
			void ViewGetViewParams(ViewParam & vp);
			void ViewDrawState(Editor::View::ViewType Type, Editor::View * view);
		public:
			Array<GxRendering::UI::GLView*> Views;
			RefPtr<Editor::View> SceneViews[4];
			ViewGrid();
			void UpdateAllViews();
			void BindView(int viewport, Editor::View * view);
			void AutoSizeViews();
			void SizeChanged();
			void HandleMessage(const UI_MsgArgs * Args);
			void Draw(int absX, int absY);
			void DoMouseMove(int X, int Y);
			void DoMouseLeave(int X, int Y);
			void DoMouseDown(int X, int Y, GxRendering::UI::SHIFTSTATE Shift);
			void DoMouseUp(int X, int Y, GxRendering::UI::SHIFTSTATE Shift);
		};
	}
}

#endif